﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using EPS.DataAccess;
using EPS.Contracts;
using System.ServiceModel;
using EPS.Common;

namespace EPS.Business
{
    //[ServiceBehavior(InstanceContextMode = InstanceContextMode.Single)]
    public class UserInfoService : IUserInfo
    {
        private CommonService _commonService = null;

        public UserInfoService()
        {
            _commonService = new CommonService();
        }

        public void Insert(EPS.Contracts.UserInfo User)
        {
            _commonService.InsertEntity(User);
        }

        public UserInfo GetById(string Keyid)
        {
            return _commonService.GetEntity<UserInfo>(p => p.Keyid == Keyid);
        }

        public void DelById(string Keyid)
        {
            _commonService.DeleteEntity<UserInfo>(p => p.Keyid == Keyid);
        }

        public bool CheckLogin(string loginName, string password)
        {
           return  _commonService.Check<UserInfo>(p => p.LoginName == loginName && p.Password==password);
        }


        public SearchResult<UserRightView> GetViewByPage(SearchFilter filter)
        {
            SearchResult<UserRightView> result = _commonService.GetByPage<UserRightView>(filter);
            return result;
        }

        //public void DoSome()
        //{
        //    // 较复杂的处理可以用这种方式组合
        //    using (CommonDataContext dc = new CommonDataContext())
        //    {
        //        dc.GetTable<UserInfo>(); 
        //    }
        //}
    }
}
